//
//  LCNavigationController.m
//  LC_BaseFramework
//
//  Created by liangrongchang on 16/8/5.
//  Copyright © 2016年 LC. All rights reserved.
//

#import "LCNavigationController.h"

@interface LCNavigationController ()<UIGestureRecognizerDelegate>

@end

@implementation LCNavigationController
#pragma mark - cycle life
+ (void)load {
    // 全局设置navBar
    UINavigationBar *navBar = [UINavigationBar appearance];
    navBar.titleTextAttributes = @{NSForegroundColorAttributeName : LCWhite};
    navBar.tintColor = LCWhite;
    navBar.barTintColor = LCBgColor;
    navBar.translucent = NO;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // 添加全屏侧滑返回
//    self.interactivePopGestureRecognizer.delegate = self;
}

#pragma mark - private method
// 可以改变视图控制器状态栏颜色
- (UIViewController *)childViewControllerForStatusBarStyle {
    return self.topViewController;
}

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
    // 不是根控制器
    if (self.childViewControllers.count) {
        viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:Image(@"back") style:0 target:self action:@selector(back)];
    }
    [super pushViewController:viewController animated:animated];
}

- (void)back {
    [self popViewControllerAnimated:YES];
}

#pragma mark - UIGestureRecognizerDelegate
// 不是根控制器时侧滑
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
    return self.childViewControllers.count > 1;
}

@end
